home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST10-11.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  910b  |  43 lines

  1. ;
  2. ; *** Listing 10-11 ***
  3. ;
  4. ; Clears a 1000-byte block of memory via BlockClear,
  5. ; which handles blocks between 0 and 64K-1 bytes in
  6. ; length.
  7. ;
  8.     jmp    Skip
  9. ;
  10. ARRAY_LENGTH    equ    1000
  11. ByteArray    db    ARRAY_LENGTH dup (?)
  12. ;
  13. ; Clears a block of memory CX bytes in length. A value
  14. ; of 0 means "clear zero bytes," so the maximum length
  15. ; that can be cleared is 64K-1 bytes and the minimum
  16. ; length is 0 bytes.
  17. ;
  18. ; Input:
  19. ;    CX = number of bytes to clear
  20. ;    ES:DI = start of block to clear
  21. ;
  22. ; Output:
  23. ;    none
  24. ;
  25. ; Registers altered: AL, CX, DI
  26. ;
  27. ; Direction flag cleared
  28. ;
  29. BlockClear:
  30.     sub    al,al    ;fill with zero
  31.     cld        ;make STOSB move DI up
  32.     rep    stosb    ;clear the block
  33.     ret
  34. ;
  35. Skip:
  36.     call    ZTimerOn
  37.     mov    di,seg ByteArray
  38.     mov    es,di    ;point ES:DI to the array to clear
  39.     mov    di,offset ByteArray
  40.     mov    cx,ARRAY_LENGTH    ;# of bytes to clear
  41.     call    BlockClear    ;clear the array
  42.     call    ZTimerOff
  43.